import 'package:backend.core/core/domain/entities/web/yookassa/yookassa_bank_card_info.dart';
import 'package:backend.purchases/domain/entities/yookassa_api/payments/yookassa_api_bank_card_info.dart';
import 'package:backend.purchases/domain/helpers/create_web_bank_card_type_from_yookassa_api_one.dart';

abstract class CreateYookassaBankCardInfoFromApiOne {
  YookassaBankCardInfo call({
    required YookassaApiBankCardInfo apiBankCardInfo,
  });
}

class CreateYookassaBankCardInfoFromApiOneImpl implements CreateYookassaBankCardInfoFromApiOne {
  const CreateYookassaBankCardInfoFromApiOneImpl({
    required CreateWebBankCardTypeFromYookassaApiOne createWebBankCardTypeFromYookassaApiOne,
  }) : _createWebBankCardTypeFromYookassaApiOne = createWebBankCardTypeFromYookassaApiOne;

  final CreateWebBankCardTypeFromYookassaApiOne _createWebBankCardTypeFromYookassaApiOne;

  @override
  YookassaBankCardInfo call({
    required YookassaApiBankCardInfo apiBankCardInfo,
  }) {
    final cardType = _createWebBankCardTypeFromYookassaApiOne(
      yookassaApiBankCardType: apiBankCardInfo.cardType,
    );

    return YookassaBankCardInfo(
      last4: apiBankCardInfo.last4,
      expirationMonth: apiBankCardInfo.expirationMonth,
      expirationYear: apiBankCardInfo.expirationYear,
      cardType: cardType,
    );
  }
}
